package lobby
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.display.Sprite;
	import lobby.exchangeddata.TransactionDetailItemInfo;
	import lobby.exchangeddata.TransactionReportInfo;
	import lobby.exchangeddata.HashTable;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author Bamboo
	 */
	public class TransactionDetailPanel extends MovieClip
	{
		
		public var txtPastTf:TextField;
		public var txtOkTf:TextField;
		public var txtDetailTf:TextField;
		public var txtTransactionBetCode:TextField;
		public var txtTransactionAmount:TextField;
		public var txtTransactionBalance:TextField;
		public var txtTransactionComm:TextField;
		public var btnCloseReport:SimpleButton;
		public var transactionMc:MovieClip;
		public var hisBoard:Sprite = new Sprite();
		public var mcScroller:MovieClip;
		public var mcMask:MovieClip;
		
		public function TransactionDetailPanel()
		{
			hide();
			transactionMc.addChild(hisBoard);
			this.btnCloseReport.addEventListener(MouseEvent.CLICK, closeHdl)
			this.txtOkTf.mouseEnabled = false;
		}
		
		private function closeHdl(e:MouseEvent):void
		{
			trace("closeHdl");
			hide();
		}
		
		public function show():void
		{
			this.visible = true;
		}
		
		public function hide():void
		{
			this.visible = false;
		}
		
		private function removeHistory():void
		{
			
			var numberChid:int = hisBoard.numChildren;
			if (numberChid > 0)
			{
				for (var j:int = 0; j < numberChid; j++)
				{
					var his:DisplayObject = hisBoard.removeChildAt(0);
					his = null;
				}
			}
		}
		
		public function updateValueTransactionReport(info:Object):void
		{
			trace("vo update");
			var transactionReport:TransactionReportInfo = TransactionReportInfo(info);
			removeHistory();
			for (var i:int = 0; i < transactionReport.dataDetailTransation.length; i++)
			{
				var itemData:TransactionDetailItemInfo = transactionReport.dataDetailTransation[i];
				var itemMc:TransactionDetailItem = new TransactionDetailItem(itemData);
				itemMc.x = 0;
				itemMc.y = i * 25 + i;
				hisBoard.addChild(itemMc);
			}
			var scroll:CustomScrollBar = new CustomScrollBar(stage, transactionMc, mcMask, mcScroller.mcTrack, mcScroller.mcButton, new SimpleButton(), new SimpleButton(), 10, false, true
				
				);
			scroll.update();
			updateTransId(GlobalVariables.langInfo.hashTable, transactionReport.transId);
			this.show();
		}
		
		public function initText(hashTableInfo:HashTable):void
		{
			this.txtPastTf.text = hashTableInfo.lookupString("MNTransferReport")
			this.txtTransactionBetCode.text = hashTableInfo.lookupString("titleTransRepBetCode");
			this.txtTransactionAmount.text = hashTableInfo.lookupString("titleTransRepAmount");
			this.txtTransactionBalance.text = hashTableInfo.lookupString("titleTransRepBalance");
			this.txtTransactionComm.text = hashTableInfo.lookupString("CommissionAmount");
			this.txtDetailTf.text = hashTableInfo.lookupString("TransDetail");
		}
		
		public function updateTransId(hashTableInfo:HashTable, value:String):void
		{
			this.txtDetailTf.text = hashTableInfo.lookupString("TransDetail") + " " + value;
		}
	}

}